#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>

int main(int argc,char*const argv[])
{
    pid_t pid;
    pid = fork();
    if(pid < 0)
    {
        perror("fail to fork");
        return -1;
    }
    else if(pid > 0)
    {
        printf("this is father_process\n");
        sleep(1);
        while(1)
        {
            printf("hello world\n");
            sleep(1);
        }
    }
    else
    {
        printf("this is son_process\n");
        sleep(3);
        //子进程睡眠3s后，向父进程发送SIGINT信号，父进程接收信号后即退出
        kill(getppid(),SIGINT);
    }
    return 0;
}